<?php
class Order
{
    private $uId;
    private $orderNo;
    private $prices;
    private $discountsKey;

    public function Order($uId, $orderNo, $prices, $discountsKey)
    {
        $this->uId = $uId;
        $this->orderNo = $orderNo;
        $this->prices = $prices;
        $this->discountsKey = $discountsKey;
    }

    public function getuId()
    {
        return $this->uId;
    }

    public function setuId($uId)
    {
        $this->uId = $uId;
    }

    public function getOrderNo()
    {
        return $this->orderNo;
    }

    public function getPrices()
    {
        return $this->prices;
    }

    public function setPrices($prices)
    {
        $this->prices = $prices;
    }

    public function getDiscountsKey()
    {
        return $this->discountsKey;
    }

    public function setDiscountsKey($discountKey)
    {
        $this->discountsKey = $discountKey;
    }
}

class ResultMsg
{
    private $code;
    private $msg;
    private $data;

    public function __construct($code, $msg, $data)
    {
        $this->code = $code;
        $this->msg = $msg;
        $this->data = $data;
    }

    public function getCode()
    {
        return $this->code;
    }

    public function setCode($code)
    {
        $this->code = $code;
    }

    public function getMsg()
    {
        return $this->msg;
    }

    public function setMsg($msg)
    {
        $this->msg = $msg;
    }

    public function getData()
    {
        return $this->data;
    }

    public function setData($data)
    {
        $this->data = $data;
    }

    public function getString()
    {
        return "使用优惠券的结果为：" .
            "成功编码：" .$this->code .
            ", 信息：'" . $this->msg . '\'' .
            ", 订单金额为：" . $this->data .
            '}';
    }
}

interface Discounts
{
    public function caculate(Order $order);
}
class FiftyMinusSeven implements Discounts
{
    private static $countPrices = 50;
    private static $limit = 7;

    public function caculate(Order $order)
    {
        if ($order->getPrices() >= self::$countPrices) {
            return new ResultMsg(200,"使用", $order->getPrices()-self::$limit);
        }
        return new ResultMsg(500,"使用失败", $order->getPrices());
    }
}



















































